Skip to content

feat(libSceLibreSsl3): release BIO references through BIO_vfree - #15599

Closed
MarrasFederico wants to merge 1 commit into
boykopovar:mainfrom
MarrasFederico:feat/libressl3-bio-vfree
Closed

MarrasFederico wants to merge 1 commit into
boykopovar:mainfrom
MarrasFederico:feat/libressl3-bio-vfree

Conversation

@MarrasFederico

@MarrasFederico MarrasFederico commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

What

BIO_vfree previously threw unconditionally. LibreSSL 4.0.0 bio_lib.c defines it as a void wrapper around BIO_free.

The export now delegates once to the existing parent BIO_free, discarding its return value. Null is a no-op, retained references are decremented, and final release follows the parent's callback/destructor and allocation rules. Its dedicated source file retains the original notices.

  • This uses the 104-byte BIO representation already created by the parent's BIO_new/memory BIO APIs and forwarded into this library. No second BIO layout or lifetime table is introduced.
  • Callback veto and chained ownership retain the existing parent's behavior. Console ABI, layout and parent limitations remain unmeasured and are recorded in the library debt.
  • The callable-placeholder count drops from 76 to 75, excluding this now-known signature. Other placeholders remain.

Neither path was measured on a console.

Tested

Ubuntu 26.04.1, kernel 7.0.0-42-generic, GCC 15, Release, BUILD_TESTING=ON, on main 086c0686c8, then again after merging main 4741457fed. Windows and macOS were not compiled here. No title was run.

  • Rebuilt guest_libressl3_bio_lifetime_tests after every source change. It covers null, a memory BIO, retained references, callback veto, a custom destructor and chained ownership with recording guest allocators. It checks actual releases, callback/destructor counts and errno preservation.
  • Main's unconditional implementation body with the new declaration/test aborts (CTest exit 8). The fix passes (exit 0). Removing the delegated free fails ownership assertions (exit 8); delegating only for the final reference fails reference-count assertions (exit 8). The restored implementation passes.
  • Complete LibreSSL3, relevant parent BIO and public-header suite: 79/79 pass. All required test targets were built with -j6. check_conventions.py --base origin/main and git diff --check pass.
  • After merging main 4741457fed: all 14 LibreSSL3 tests pass, including guest_libressl3_bio_lifetime. The only conflict was the pending-export count in the debt file, now 67 with BIO_vfree excluded.
  • pr_overlap.py examined 1777 open PRs. Reported shared debt-count/insertion hunks require reconciliation with other library PRs; none implements BIO_vfree. In particular, #12945 adds BIO_up_ref and uses a separate 112-byte model. This wrapper uses the current parent's 104-byte BIO; future retain/release interoperability between those models needs reconciliation before combining them.

I inspected every not-compared branch diff and confirmed that its BIO_vfree remains the unconditional placeholder. Their shared-file changes concern:

  • #10461: ASN1_OBJECT_free ownership.
  • #10631: OBJ_cmp comparison.
  • #11146: EC private-key support and retain/lifetime debt.
  • #12754: SSL/X509 retains, protocol bounds and random/version accessors.
  • #12928: BIO adapters in the parent; shared child changes concern error-loader/queue forwarding.
  • #13486: broader platform changes; shared child changes concern stack registration and export inventory.
  • #14212: debt spacing and count removal.
  • #14483: SSL_CIPHER_get_id.
  • #14499: EVP_PKEY_get0_EC_KEY.
  • #14612: AES_unwrap_key.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Progress report (502288c → e100607)

📈 System libraries: 31.22% (+0.0026%, +1 implemented functions)

✅ 1 implemented
Library Name
libSceLibreSsl3 BIO_vfree_nid_postfix

Changed libraries (implemented exports)

Library Before After Change
libSceLibreSsl3 81/284 (28.52%) 82/284 (28.87%) +0.35%

@TechLevelZero

Copy link
Copy Markdown
Contributor

✅ AMD GPU test: passed

PR head d1a22de merged onto main 1c8c0ef · tested 2026-11-04 05:21 UTC · 17 min

GPU AMD Radeon RX 6300 (RADV NAVI24), driver Mesa 25.2.8-0ubuntu0.24.04.4, Vulkan 1.4.318
Host Ubuntu 26.04.1 LTS, kernel 7.0.0-42-generic, container ubuntu:24.04
Logs build and test logs for this run
Build ✅ passed (Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON)
Tests ✅ 1,129 passed · 4 failed (0 new, 3 also fail on main, 1 unstable on main) · 7 skipped (ANYPS5_REQUIRE_VULKAN=1)
Test setup CPU-only tests without a GPU; GPU tests (and any CPU-only test that failed or skipped without one) once on the GPU with VK_LAYER_KHRONOS_validation and ANYPS5_NO_SHADER_CACHE=1; main ran the same way
Test selection 1,140 of 3,842 tests run: the ones this change can reach, chosen by tools/select_tests.py from main's build graph
Vulkan validation ✅ no new validation IDs vs main (549 tests run on the GPU)
Slow tests (>30 s, GPU tests timed with validation layers) ⚠️ agc_driver_pipeline_journal 120.0 s, ⚠️ agc_driver_image_sample_unnormalized 53.9 s, ⚠️ public_headers 50.0 s, ⚠️ agc_driver_lazy_resolved_abi 44.6 s, ⚠️ agc_driver_sample_multisample_target 34.7 s
Unstable on main (1, these also failed in recent main runs on this machine; not counted against this PR)
agc_driver_pipeline_journal: failed in 8 of the last 10 main runs
Failing on main too (3, not counted against this PR)
agc_driver_image_table
agc_driver_native_depth_bda_clear
agc_driver_native_multisample_depth
Validation IDs already present on main (8 IDs in 470 tests)
VUID-VkDeviceCreateInfo-pNext-pNext (470 tests): agc_driver_address_passes, agc_driver_alias_copy_label, agc_driver_alpha_to_coverage, agc_driver_array_layer_target, agc_driver_bc_block_copy, agc_driver_bda_anchor_reads, agc_driver_bda_span_reads, agc_driver_bindless_images, and 462 more
VUID-vkCmdCopyImage-srcImage-01548 (4 tests): agc_driver_depth_clear_hle, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth
VUID-vkCmdCopyImage-srcImage-01551 (4 tests): agc_driver_depth_clear_hle, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth
VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 (1 test): agc_driver_srgb8_color_target
VUID-VkSamplerCreateInfo-addressModeU-01079 (1 test): agc_driver_image_gather_volume
VUID-VkSamplerCreateInfo-addressModeU-parameter (1 test): agc_driver_image_gather_volume
VUID-VkSamplerCreateInfo-addressModeV-parameter (1 test): agc_driver_image_gather_volume
VUID-VkSamplerCreateInfo-addressModeW-parameter (1 test): agc_driver_image_gather_volume
Skipped (7)
agc_driver_copied_writer_label_order: skipped, the device reports a minStorageBufferOffsetAlignment of 4, so the dispatch binds its record at +0x1004 in place and nothing is written back; the test needs an alignment above 4
agc_driver_float16_unused_nan_payloads: skipped, the device has no native f16 conversions with RTE rounding and kept f16 denormals
agc_driver_gcn_display_present: skipped, no display: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
agc_driver_linear_target_direct_write_completion: skipped, the device does not keep host imports write-watched, so no completion stamp over the target is tracked
agc_driver_ngg_vertex_wave_reduction: skipped, s3 describes a 32-lane wave only on 32-lane subgroups, and the device has 64 lanes
agc_driver_scattered_runs: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_driver_sparse_dma_buf_import: skipped, host imports are unavailable: /dev/udmabuf is not accessible
Reproduce
git fetch origin d1a22deb4f62276bc8b3b4131180323962bb7354 1c8c0efc8c41314402e6966da5bef6ea3d639d10
git checkout 1c8c0efc8c41314402e6966da5bef6ea3d639d10 && git merge --no-ff d1a22deb4f62276bc8b3b4131180323962bb7354
git submodule update --init --recursive
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON
cmake --build build && cmake --build build --target libs
VK_DRIVER_FILES=/nonexistent/icd.json ctest --test-dir build -E '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 12 --output-on-failure
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
  ctest --test-dir build -R '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 16 --output-on-failure
# failures are then re-run alone: --timeout 360 --parallel 2; new validation IDs: the test alone, twice, --parallel 1

Automated build and test on a contributor's AMD machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs.

@B-Howell

B-Howell commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

I prepared an ordinary merge of main at B-Howell:unstick/pr-15599 if you’d like to use it. It merges main at 78e4248fea and resolves the LibreSSL3 debt-list conflict. On Windows and WSL, BIO lifetime passed 3/3 runs and public headers passed 65/65 checks per platform. AI-assisted: Codex.

@MarrasFederico

Copy link
Copy Markdown
Contributor Author

@B-Howell thanks for preparing it. Main had moved on to 4741457fed by then, so I merged it myself in 23978ab. The debt-list resolution is the same as yours, line for line: 67 pending exports, with BIO_vfree added to the exclusions. All 14 LibreSSL3 tests pass on Ubuntu, including guest_libressl3_bio_lifetime.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 5, 2026
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 5, 2026
@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Nov 6, 2026
@MarrasFederico

Copy link
Copy Markdown
Contributor Author

I merged current main in 40fcc8d. It brings #12945's BIO_up_ref, so I kept both exports: its typed declaration and this PR's BIO_vfree. The pending count is now 44, and both names are in the exclusion list. All 26 LibreSSL3 tests pass on Ubuntu.

While resolving it I noticed the two exports assume different BIO layouts, which reviewers may want to settle separately:

  • BIO_up_ref (feat(libSceLibreSsl3): implement BIO_up_ref #12945) uses the 112-byte LibreSSL 4.0.0 LibreSsl3Bio, with references at offset 80.
  • The BIOs this module actually returns come from the parent library: BIO_new, BIO_new_mem_buf, BIO_new_socket, BIO_new_fp and BIO_free are forwarded (ParentExports.cpp on Windows, ELF dependency lookup elsewhere). Those objects use libSceLibreSsl's 104-byte LibreSsl::Bio, with references at offset 72 (include/Bio.hpp).
  • This PR's BIO_vfree delegates to the parent BIO_free, so it matches the objects callers really hold. BIO_up_ref on the same object would instead increment offset 80, which is the low half of bytesRead in the parent layout, and leave the reference count unchanged. A later BIO_vfree or BIO_free would then release a BIO the caller still expects to own.

I left BIO_up_ref unchanged here, since this PR is about BIO_vfree. A follow-up could have BIO_up_ref retain through the parent layout, as long as BIO creation stays forwarded.

@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Nov 6, 2026
@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 15449 core/libs/prx/libSceLibreSsl3/CMakeLists.txt L18
PR 15544 docs/dev/debt/libSceLibreSsl3.md L19
PR 16529 core/libs/prx/libSceLibreSsl3/Export.cpp L10-15
core/libs/prx/libSceLibreSsl3/include/Api.hpp L122
BIO_vfree
PR 16535 docs/dev/debt/libSceLibreSsl3.md L19

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 12315 core/libs/prx/libSceLibreSsl3/CMakeLists.txt
core/libs/prx/libSceLibreSsl3/Export.cpp
core/libs/prx/libSceLibreSsl3/include/Api.hpp
docs/dev/debt/libSceLibreSsl3.md
PR 14212 docs/dev/debt/libSceLibreSsl3.md
PR 14465 core/libs/prx/libSceLibreSsl3/CMakeLists.txt
core/libs/prx/libSceLibreSsl3/include/Api.hpp
docs/dev/debt/libSceLibreSsl3.md
PR 14499 core/libs/prx/libSceLibreSsl3/include/Api.hpp
docs/dev/debt/libSceLibreSsl3.md
PR 14612 core/libs/prx/libSceLibreSsl3/CMakeLists.txt
core/libs/prx/libSceLibreSsl3/include/Api.hpp
docs/dev/debt/libSceLibreSsl3.md
PR 15163 core/libs/prx/libSceLibreSsl3/Export.cpp
core/libs/prx/libSceLibreSsl3/include/Api.hpp
docs/dev/debt/libSceLibreSsl3.md
PR 15514 core/libs/prx/libSceLibreSsl3/CMakeLists.txt
core/libs/prx/libSceLibreSsl3/include/Api.hpp
docs/dev/debt/libSceLibreSsl3.md
PR 15826 core/libs/prx/libSceLibreSsl3/CMakeLists.txt
core/libs/prx/libSceLibreSsl3/include/Api.hpp
docs/dev/debt/libSceLibreSsl3.md
PR 15831 core/libs/prx/libSceLibreSsl3/CMakeLists.txt
core/libs/prx/libSceLibreSsl3/include/Api.hpp
docs/dev/debt/libSceLibreSsl3.md
PR 15854 core/libs/prx/libSceLibreSsl3/CMakeLists.txt
core/libs/prx/libSceLibreSsl3/include/Api.hpp
docs/dev/debt/libSceLibreSsl3.md

@adriadam10 adriadam10 self-assigned this Nov 7, 2026
Replace BIO_vfree's unknown-signature placeholder with void(Bio*), delegating directly to BIO_free_nid_postfix using the existing parent libSceLibreSsl BIO representation. Null input is a no-op, refcounts >1 decrement by one reference without destruction, and a final reference executes callback/destructor cleanup following the parent contract.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants